<%--
  Created by IntelliJ IDEA.
  User: ZhuChunXiao
  Date: 2017/6/5
  Time: 10:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<div class="row">
  <div class="col-lg-12">
    <div class="panel">
      <div class="panel-heading header">
        <h3 class="panel-title" id="title">订单跟踪表</h3>
      </div>
<form id="form_ordertrack_input" class="panel-body form-horizontal form-padding">
  <input type="hidden" name="keyId" id="keyId" value="${orderTrack.id}" />
  <input type="hidden" name="parentId" id="parentId" value="${orderTrack.orderEntity.id}" />
  <input type="hidden" name="curDutyId" id="curDutyId" value=""/>

  <div class="form-group" id="tempWidth1">
    <label class="col-md-2 control-label">订单编号<i class="fa fa-asterisk txt-color-red"></i></label>
    <div class="col-md-6">
      <input disabled type="number" id="orderNo" name="orderNo" class="form-control" placeholder="请输入订单编号" value="${orderTrack.orderEntity.orderNo}">
    </div>
  </div>

  <div class="form-group div-Hidden">
    <label class="col-md-2 control-label">订单下达时间<i class="fa fa-asterisk txt-color-red"></i></label>
    <div class="col-md-6">
      <div class="input-group date">
        <input disabled type="text" class="form-control" id="issuedDate" name="issuedDate" placeholder="请选择订单下达时间"
               value=<fmt:formatDate pattern="yyyy-MM-dd" value="${orderTrack.orderEntity.issuedDate}" /> >
        <span class="input-group-addon"><i class="ti-calendar"></i></span>
      </div>
    </div>
  </div>

  <div class="form-group div-Hidden">
    <label class="col-md-2 control-label">期望交付时间<i class="fa fa-asterisk txt-color-red"></i></label>
    <div class="col-md-6">
      <div class="input-group date">
        <input disabled type="text" class="form-control" id="deliverDate" name="deliverDate" placeholder="请选择期望交付时间"
               value=<fmt:formatDate pattern="yyyy-MM-dd" value="${orderTrack.orderEntity.deliverDate}" /> >
        <span class="input-group-addon"><i class="ti-calendar"></i></span>
      </div>
    </div>
  </div>

  <div class="form-group div-Hidden">
    <label class="col-md-2 control-label">订单跟踪时间<i class="fa fa-asterisk txt-color-red"></i></label>
    <div class="col-md-6">
      <div class="input-group date">
        <input disabled type="text" class="form-control" id="trackDate" name="trackDate" placeholder="请选择订单跟踪时间"
               value=<fmt:formatDate pattern="yyyy-MM-dd" value="${orderTrack.trackDate}" /> >
        <span class="input-group-addon"><i class="ti-calendar"></i></span>
      </div>
    </div>
  </div>

  <div class="form-group div-Hidden">
    <label class="col-md-2 control-label">订单完成比率<i class="fa fa-asterisk txt-color-red"></i></label>
    <div class="col-md-6">
      <%--<div class="input-group">--%>
        <input disabled type="text" class="form-control" id="rate" name="rate" placeholder="请输入订单完成比率" value="${rate}" >
        <%--<span class="input-group-addon">%</span>--%>
      <%--</div>--%>
    </div>
  </div>

  <div class="form-group">
    <label class="col-md-2 control-label">完成情况说明<i class="fa fa-asterisk txt-color-red"></i></label>
    <div class="col-md-6">
      <input disabled type="text" id="completion" name="completion" class="form-control" placeholder="请输入完成情况说明" value="${orderTrack.completion}">
    </div>
  </div>

  <div class="form-group">
    <label class="col-md-2 control-label">是否有障碍问题<i class="fa fa-asterisk txt-color-red"></i>
    </label>
    <div class="col-md-6">
      <div class="radio">
        <!-- Inline radio buttons -->
        <input disabled type="radio" name="difficulty" id="difficulty1Selected" class="magic-radio" value="2"
        <c:if test="${orderTrack.difficulty eq 2}"> checked="checked"</c:if> >
        <label for="difficulty1Selected">是</label>

        <input disabled type="radio" name="difficulty" id="difficulty2Selected" class="magic-radio" value="1"
        <c:if test="${orderTrack.difficulty eq 1}"> checked="checked"</c:if> >
        <label for="difficulty2Selected">否</label>

      </div>
    </div>
  </div>

  <div class="form-group" id="showDifficultyText" <c:if test="${orderTrack.difficulty==0||orderTrack.difficulty==1}">style="display: none"</c:if>>
    <label class="col-md-2 control-label">障碍情况描述<i class="fa fa-asterisk txt-color-red"></i></label>
    <div class="col-md-6">
      <input disabled type="text" id="difficultyText" name="difficultyText" class="form-control" placeholder="请输入障碍情况描述" value="${orderTrack.difficultyText}">
    </div>
  </div>

  <div class="form-group" id="showOvercome" <c:if test="${orderTrack.difficulty==0||orderTrack.difficulty==1}">style="display: none"</c:if>>
    <label class="col-md-2 control-label">障碍克服情况<i class="fa fa-asterisk txt-color-red"></i>
    </label>
    <div class="col-md-6">
      <div class="radio">
        <!-- Inline radio buttons -->
        <input disabled type="radio" name="overcome" id="overcome1Selected" class="magic-radio" value="2"
        <c:if test="${orderTrack.overcome eq 2}"> checked="checked"</c:if> >
        <label for="overcome1Selected">已克服</label>

        <input disabled type="radio" name="overcome" id="overcome2Selected" class="magic-radio" value="1"
        <c:if test="${orderTrack.overcome eq 1}"> checked="checked"</c:if> >
        <label for="overcome2Selected">未克服</label>

      </div>
    </div>
  </div>


  <div class="form-group">
    <label class="col-md-2 control-label">提交人</label>
    <div class="col-md-2">
      <p class="form-control-static">${orderTrack.creater.name}</p>
    </div>
    <label class="col-md-2 control-label">提交日期</label>
    <div class="col-md-2">
      <p class="form-control-static"><fmt:formatDate pattern="yyyy-MM-dd" value="${orderTrack.createTime}" /></p>
    </div>
  </div>

  <c:if test='${(orderTrack.processState=="Running" || orderTrack.processState=="Backed") && stepNo !=1 && stepNo !=0}'>
    <div class="form-group" id="comment">
      <label class="col-md-2 control-label">审批意见</label>
      <div class="col-md-6">
        <textarea name="editor" id="editor" style="height:200px;"></textarea>
      </div>
    </div>
  </c:if>

  <div class="flow">
    <div class="panel-footer">
      <a class="btn btn-default" id="apply-re-common2" href="javascript:void(0)">
        <i class="fa fa-lg fa-mail-reply"></i> 返回
      </a>
      <a class="btn btn-default" key="ajax_edit2" href="javascript:void(0);" ${isEdit}>
        <i class="fa fa-lg fa-edit"></i> 编辑
      </a>
    </div>

    <div class="f_title"><i class="right" id="flow2"></i>流程信息</div>
    <div class="f_content" style="display:none">
      <div id="showFlow2"></div>
    </div>
    <div class="f_title"><i class="right" id="next2"></i>下一步骤提示</div>
    <div class="f_content" style="display:none">
      <div id="showNext2"></div>
    </div>
  </div>
  
</form>
    </div>
  </div>
</div>
<!--===================================================-->
<!-- END BASIC FORM ELEMENTS -->

<script>
  var index = "${index}";
  var todo = "${todo}";
  var remind = "${remind}";
  var record = "${record}";
  var draft =  "${draft}";
  var stepNo = "${stepNo}";

  $(function(){
    loadURL("<%=path%>/com/running/workflow?bussinessId="+$("#form_ordertrack_input #keyId").val()+"&type=flow",$('#showFlow2'));
    loadURL("<%=path%>/com/running/workflow?bussinessId="+$("#form_ordertrack_input #keyId").val()+"&type=next",$('#showNext2'));
    __ajax_post("<%=path%>/com/running/operateType",{keyId: $("#form_ordertrack_input #keyId").val()},function(pdata){
      var showDuty = false;
      var area = $("form .panel-footer");
      var edit = null;
      if (stepNo == 1){
        return false;
      }
      $(pdata.datarows).each(function(i,v){
        var str = '<a id="left_foot_btn_'+ v.action+'" class="btn btn-warning" href="javascript:void(0);"><i class="fa fa-upload">'+ v.name+'</i></a>&nbsp;';
        $(area).append(str);
        if(v.action == "approve" || v.action=="sendback"  || v.action=="deny"){
          showDuty = true;
        }
      });
      if(showDuty == true){
        var pdata = {
          keyId: $("#form_ordertrack_input #keyId").val(),
          entityName: "com.fz.us.oa.core.entity.com.OrderTrack"
        };
        multiDuty(pdata);
      }else{
        $('#comment').hide();
      }
      if($(':visible#editor').length == 1){
        edit  = new UE.ui.Editor();
        edit.render('editor');
        /*
         edit.ready(function() {
         edit.setContent("");
         });*/
      }
      //通过
      $("#form_ordertrack_input #left_foot_btn_approve").off("click").on("click",function(){
        var comment = "";
        if(edit != null){
          comment = encodeURIComponent(edit.getContent());
        }
        if($.trim(comment) == ""){
          alert("请填写审批意见");
          return false;
        }
        __form_save("form_ordertrack_input","<%=path%>/com/orderTrack/approve?comment="+comment,function(){
          $("#apply-re-common2").trigger("click");
        })
      });
      //退回
      $("#form_ordertrack_input #left_foot_btn_sendback").off("click").on("click",function(){
        var comment = "";
        if(edit != null){
          comment = encodeURIComponent(edit.getContent());
        }
        if($.trim(comment) == ""){
          alert("请填写审批意见");
          return false;
        }
        var vActionUrl="<%=path%>/com/orderTrack/back?comment="+comment+"&curDutyId="+$('#curDutyId').val();
        var data={keyId:$("#form_ordertrack_input #keyId").val()};
        __ajax_post(vActionUrl,data,function(pdata){
          __toastr(pdata);
          $("#apply-re-common2").trigger("click");
        });
      });
      //否决
      $("#form_ordertrack_input #left_foot_btn_deny").off("click").on("click",function(){
        var comment = "";
        if(edit != null){
          comment = encodeURIComponent(edit.getContent());
        }
        if($.trim(comment) == ""){
          alert("请填写审批意见");
          return false;
        }
        var vActionUrl="<%=path%>/com/orderTrack/deny?comment="+comment+"&curDutyId="+$('#curDutyId').val();
        var data={keyId:$("#form_ordertrack_input #keyId").val()};
        __ajax_post(vActionUrl,data,function(pdata){
          __toastr(pdata);
          $("#apply-re-common2").trigger("click");
        });
      });
    });

    //流程信息展开
    $('#flow2,#next2').click(function(){
      if($(this).hasClass("right")){
        $(this).removeClass("right").addClass("down");
        $(this).parent(".f_title").next("div.f_content").show();
      }else{
        $(this).removeClass("down").addClass("right");
        $(this).parent(".f_title").next("div.f_content").hide();
      }
    });
  });

  //返回视图
  $("#apply-re-common2").click(function(){
    if(index==1){
      loadURL("menu/dashboard",$('#page-content'));
    }else if(todo==1){
      loadURL("menu/toDo",$('#page-content'));
    }else if(remind==1){
      loadURL("menu/remind",$('#page-content'));
    }else if(record==1){
      loadURL("menu/taskRecord?type=1",$('#page-content'));
    }else if(record==2){
      loadURL("menu/taskRecord?type=2",$('#page-content'));
    }else if(draft==1){
      loadURL("menu/draft",$('#page-content'));
    }else{
      var parentId=$("#form_ordertrack_input #parentId").val();
      var table_global_width = $("#s1").is(":visible") ? $("#s1").width() : $("#s2").width();
      $('div').data("table_global_width", table_global_width);
      loadURL("<%=path%>/com/orderTrack/toList?parentId="+parentId,$('#s2'));
    }
  });

  //编辑
  $("a[key='ajax_edit2']").unbind("click").bind("click",function(){
    __confirm_dialog("提示：","确定要编辑基本信息吗？",
            function () {
              // 加载编辑页面
              loadURL("<%=path%>/com/orderTrack/input?keyId="+$("#form_ordertrack_input #keyId").val()+"&parentId="+$("#form_ordertrack_input #parentId").val()+"&draft="+draft+"&todo="+todo+"&remind="+remind+"&record="+record+"&index="+index,$('#page-content'));
            }
    )
  });

</script>